import React, { Component } from 'react'
import { Form, Input, Button, Modal } from 'antd'
import ModalConfigure from "@/assets/utils/modalConfigure";
class AddSubject extends Component {
    constructor(props) {
        super(props)
    }
    state = {
        modalFlg: false,
        title: "添加",
        name: undefined,
        id: "",
    }
    onCancelFn = (res) => {
        this.closeFn();
    }
    closeFn = () => {
        this.setState({
            modalFlg: false,
            title: "添加",
            name: undefined,
            id: undefined,
        })
    }
    onOkFn = (res) => {
        console.log(this.state.name);
        this.closeFn();
    }
    initFn = (data = "") => {
        if (data) {
            this.setState({
                modalFlg: true,
                title: "修改",
                name: data.name,
                id: data.key,
            })
        } else {
            this.setState({ modalFlg: true })
        }
    }
    inputChangeFn = (event) => {
        this.setState({ name: event.target.value })
    }
    render() {
        return (
            <Modal title={`${this.state.title}学习科目`} visible={this.state.modalFlg} width="500px" onCancel={this.onCancelFn} onOk={this.onOkFn}  {...ModalConfigure}>
                <Form>
                    <Form.Item label="科目名称">
                        <Input className="w-100" value={this.state.name} onChange={this.inputChangeFn} placeholder="请输入科目名称，最多六个字符" maxLength="10" />
                    </Form.Item>
                </Form>
            </Modal>
        )
    }
}
export default AddSubject;